package com.xjtu.task;

import com.xjtu.mapper.MedicationMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class MedicationTask {
    @Autowired(required = false)
    private MedicationMapper medicationMapper;

    @Scheduled(cron = "0 0 23 * * *") //
    public void processTimeoutOrder(){
        int number = medicationMapper.refreshRemain();
        if(number <= 0){
            log.info("今日无剩余药物更新/更新失败");
        } else {
            log.info("今日有{}条药物更新记录", number);
        }
    }
}
